<?php
/**
* Admin JoomlaSEF17 Controller
*
* This handles all AJAX requests from the Admin GUI JoomlaSEF17 Configuration page.
* These methods will create an AJAX response containing JSON data. The JSON
* data is read by the JS code and rendered into interface.
*
* @access 	public
* @author 	Rob, Valentin
* @copyright	ResMania 2009 all rights reserved.
* @version	1.0
* @link		http://developer.resmania.com/api
* @since  	05-2009
*/
class RM_Admin_JoomlaSEF17Controller extends RM_Controller
{
    /**
     * This loads the joomlasef17 configuration, the data is retrieved using the
     * RM_JoomlaSEF17 class
     *
     * @return 	json    json array information containing joomlasef17 information
     */
    public function configJsonAction(){

        $joomlasef17Obj = new RM_JoomlaSEF17;
        $settings = $joomlasef17Obj->getSettings()->toArray();

        $json = new stdClass;
        $json->settings = $settings;

        return array(
            'data' => $json
        );
    }

    /**
     * This saves the joomlasef17 settings from the plugin->joomlasef17 setting page
     *
     * @return 	json    success value true/false
     */
    public function updateJsonAction(){

        $aliasname = $this->_getParam('aliasname');

        $joomlasef17Obj = new RM_JoomlaSEF17;
        $details = $joomlasef17Obj->find(1)->current();

        $status = true;
        $details->aliasname = $aliasname;
        $result = $details->save();

        if ($result!='1') $status = 'false';
        
        return array(
            'data' => array('success' => $status)
        );

    }
}